/**
 * 格式化时间
 * @param time 时间  string | number | Date
 * @param format 格式化字符串
 * @returns 格式化后的时间
 */
export const formatTime = (time, format = 'yyyy-MM-dd HH:mm:ss') => {
    if (!time) {
        return ''
    }
    const date = new Date(time)
    const year = date.getFullYear()
    const month = date.getMonth() + 1
    const day = date.getDate()
    const hour = date.getHours()
    const minute = date.getMinutes()
    const second = date.getSeconds()
    return format.replace('yyyy', year.toString()).replace('MM', month.toString().padStart(2, '0')).replace('dd', day.toString().padStart(2, '0')).replace('HH', hour.toString().padStart(2, '0')).replace('mm', minute.toString().padStart(2, '0')).replace('ss', second.toString().padStart(2, '0'))
}